﻿@using ThuySan.Areas.Backend.Models
@using ThuySan.Bussiness
@{
    Layout = "~/Areas/Backend/Views/Shared/_Layout.cshtml";
    Header header = new Header
    {
        Common = "ViewUserControl_Category_Index",
        CurentCommon = "Category",
        PageHeader = "Manage Category",
        Menulv1 = "01",
        Menulv2 = "0101"
    };
    ViewData[Header.Key] = header;
    ViewBag.Title = "Manage Category - Admin Control Panel";
}
@(Html.Telerik().Grid<Category>().Name("grid").Columns(c =>
                                                           {
                                                               c.Bound(typeof(int), "CategoryId").Title("#").Width(50);
                                                               c.Bound(typeof(string), "Name");
                                                               c.Bound(typeof(int), "Priority");
                                                               c.Template(v => v.CategoryId).ClientTemplate(Html.ActionLink("<span class=\"t-icon t-edit\"></span>", "Edit", new
                                                               {
                                                                   id = "<#=CategoryId#>"
                                                               }, new
                                                               {
                                                                   @class = "t-button t-button-icon t-grid-edit",
                                                               }).ToHtmlString() + "<a class=\"t-button t-button-icon t-grid-delete\" href=\"javascript:Delete(<#=CategoryId#>);\"><span class=\"t-icon t-delete\"></span></a>").Width(80);
                                                           }).Sortable(c => c.Enabled(true)).Filterable().DataKeys(c => c.Add("CategoryId")).Pageable(c =>
                                                                                                                                             {
                                                                                                                                                 c.Enabled(true);
                                                                                                                                                 c.PageSize(25);
                                                                                                                                             }).DataBinding(c => c.Ajax().Select("GetList", "Category")))
@section script
{
    <script type="text/javascript">
        function Delete(id) {
            if (confirm("Do you want to delete?"))
                $.post('@Url.Action("Delete", "Category")', { id: id }, function () {
                    $("#grid").data("tGrid").ajaxRequest();
                });
        }
    </script>
}
